using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;
using Utility;

namespace BUS
{
    public class LOAINGUOIDUNG
    {
        public static void insert(LoaiNguoiDung_DTO loainguoidung)
        {
           LOAINGUOIDUNG_DAL loainguoidungdal = new LOAINGUOIDUNG_DAL();
            loainguoidungdal.insert(loainguoidung);
        }
        public static void update(LoaiNguoiDung_DTO loainguoidung)
        {
            LOAINGUOIDUNG_DAL loainguoidungdal = new LOAINGUOIDUNG_DAL();
            loainguoidungdal.update(loainguoidung);
        }
        public static void delete(int manguoidung)
        {
            LOAIHANG_DAL loainguoidungdal = new LOAIHANG_DAL();
            loainguoidungdal.delete(manguoidung);
        }

        public static tbLoaiNguoiDungCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            LOAINGUOIDUNG_DAL loainguoidungdal = new LOAINGUOIDUNG_DAL();
            return loainguoidungdal.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbLoaiNguoiDungCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            LOAINGUOIDUNG_DAL loainguoidungdal = new LOAINGUOIDUNG_DAL();
            return loainguoidungdal.Get(cri.Criter, 0, 0, tbLoaiNguoiDungColumns.MaLoai_NguoiDung.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static LoaiNguoiDung_DTO GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbLoaiNguoiDungColumns.MaLoai_NguoiDung.ToString(), Condition.EQUAL, iD);
           LOAINGUOIDUNG_DAL loainguoidungdal = new LOAINGUOIDUNG_DAL();
           tbLoaiNguoiDungCollection lndungcltion = loainguoidungdal.Get(cri.Criter, 0, 0, tbLoaiNguoiDungColumns.MaLoai_NguoiDung.ToString(), OrderDirection.ASC.ToString(), out total);
            if (lndungcltion.Count > 0)
                return lndungcltion[0];
            return null;

        }

    }
}
